package com.csxy.ljr.controller;

import com.alibaba.fastjson.JSONObject;
import com.csxy.ljr.R;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/acl/index")
public class IndexController {

    /**
     * 根据token获取用户信息
     */
    @GetMapping("info")
    public R info(){
        // Mock data
        Map<String, Object> map = new HashMap<>();
        map.put("name", "admin");
        map.put("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        map.put("roles", "[admin]");
        return R.ok().data(map);
    }

    /**
     * 获取菜单
     * @return
     */
    @GetMapping("menu")
    public R getMenu(){
        // Mock data
        JSONObject permission1 = new JSONObject();
        permission1.put("path", "/acl");
        permission1.put("component", "layout");
        permission1.put("name", "权限管理");
        
        return R.ok().data("permissionList", List.of(permission1));
    }

    @PostMapping("logout")
    public R logout(){
        return R.ok();
    }

} 